package com.dfrz.household.utils;

/**
 * Create by keyan on 2021/7/29 17:43
 */
public class ResultUtils {
    public static Result success(Object obj){
        Result result =new Result();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(obj);
        result.setCount(null);
        return  result;
    }
    /**
     * 返回成功但不带数据
     * @return
     */
    public static Result success(){
        return success(null);
    }

    public static Result unKnowError(Object obj){
        Result result =new Result();
        result.setCode(ResultEnum.UNKNOWN_ERROR.getCode());
        result.setMsg(ResultEnum.UNKNOWN_ERROR.getMsg());
        result.setData(obj);
        result.setCount(null);
        return  result;
    }

    public static Result userNotExist(Object obj){
        Result result =new Result();
        result.setCode(ResultEnum.USER_NOT_EXIST.getCode());
        result.setMsg(ResultEnum.USER_NOT_EXIST.getMsg());
        result.setData(obj);
        result.setCount(null);
        return  result;
    }
    public static Result userNotExists(Object obj){
        Result result =new Result();
        result.setCode(ResultEnum.USER_IS_EXISTS.getCode());
        result.setMsg(ResultEnum.USER_IS_EXISTS.getMsg());
        result.setData(obj);
        result.setCount(null);
        return  result;
    }
    public static Result dataIsNull(Object obj){
        Result result =new Result();
        result.setCode(ResultEnum.DATA_IS_NULL.getCode());
        result.setMsg(ResultEnum.DATA_IS_NULL.getMsg());
        result.setData(obj);
        result.setCount(null);
        return  result;
    }
    public static Result loginFailed(Object obj){
        Result result =new Result();
        result.setCode(ResultEnum.LOGIN_FAILED.getCode());
        result.setMsg(ResultEnum.LOGIN_FAILED.getMsg());
        result.setData(obj);
        result.setCount(null);
        return  result;
    }
    public static Result noPermission(Object obj){
        Result result = new Result();
        result.setCode(ResultEnum.NO_PERMISSIONS.getCode());
        result.setMsg(ResultEnum.NO_PERMISSIONS.getMsg());
        result.setData(obj);
        result.setCount(null);
        return result;
    }
    public static Result validatecodeFailed(Object obj){
        Result result = new Result();
        result.setCode(ResultEnum.NO_PERMISSIONS.getCode());
        result.setMsg(ResultEnum.NO_PERMISSIONS.getMsg());
        result.setData(obj);
        result.setCount(null);
        return result;
    }

    public static void main(String[] args) {
        Result success = ResultUtils.success(null);
        System.out.println(success);
    }
}
